home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Frameworks / TransSkel 3.24 / Source / Positioning Stuff / SkelPosWindow.c < prev    next >
Text File  |  1996-01-17  |  2KB  |  52 lines

  1. /*
  2.  * Position a window according to the given position type, using the
  3.  * given positioning ratios.
  4.  *
  5.  * Position types:
  6.  *    skelPositionNone -- leave window in current position
  7.  *    skelPositionOnMainDevice -- position on main device
  8.  *    skelPositionOnParentWindow -- position on frontmost visible window
  9.  *    skelPositionOnParentScreen -- position on screen of frontmost visible window
  10.  *
  11.  * If there's no frontmost window, positions that use it default to
  12.  * skelPositionOnMainDevice.
  13.  *
  14.  * For best results, window should not be visible.  Otherwise you'll end
  15.  * up moving it while it's visible.
  16.  *
  17.  * 08 Feb 94
  18.  * - Position window using structure rather than content rectangle.
  19.  */
  20.  
  21. # include    "TransSkel.h"
  22.  
  23.  
  24. pascal void
  25. SkelPositionWindow (WindowPtr w, short positionType,
  26.                             Fixed hRatio, Fixed vRatio)
  27. {
  28. Rect    contentRect, structRect, refRect;
  29. short    hDiff, vDiff;
  30.  
  31.     if (positionType == skelPositionNone)    /* leave window as is */
  32.         return;
  33.  
  34.     /* get rect to use as reference against which to position window rect */
  35.     SkelGetReferenceRect (&refRect, positionType);
  36.  
  37.     /*
  38.      * Use structure rect as the rect to be positioned, but when moving window,
  39.      * offset by difference between upper left of structure and content rects,
  40.      * since MoveWindow() positions the content rect to the given position.
  41.      */
  42.     SkelGetWindContentRect (w, &contentRect);
  43.     SkelGetWindStructureRect (w, &structRect);
  44.     hDiff = contentRect.left - structRect.left;
  45.     vDiff = contentRect.top - structRect.top;
  46.     SkelPositionRect (&refRect, &structRect, hRatio, vRatio);
  47.     MoveWindow (w,
  48.                 structRect.left + hDiff,
  49.                 structRect.top + vDiff,
  50.                 false);
  51. }
  52.